ATTENTION!! PLEASE RUN ALL THE CODE BELOW TO ENSURE ALL THE VARIABLES ARE IN THE GLOBAL ENVIRONMENT BEFORE LOOKING THROUGH THE ‘FINAL PROJECT’ FILE. SHORTCUT TO RUN ALL THE BELOW CODE: COMMAND + OPTION + R
Load Tidyverse
library(tidyverse)
library(broom)
# load other packages AS NEEDED and ONLY IF YOU *REALLY* NEED THEM#Load Data Load your data here:
fifa_data <- read.csv('data/fifa.raw.data.csv') #Import function used#Exploratory data analysis Figure 1: Histogram of Overall Scores of players.
fifa_data %>%
ggplot(aes(x = Overall))+
geom_histogram(bins = 100)Figure 2: Scatter plot between Price and Overall score
fifa_data %>%
filter(Price > 0) %>%
ggplot(data = .,aes(x = Overall, y= Price))+
geom_point()+
geom_vline(xintercept = 65, color = "Red")Figure 2.1 Scatter plot between log_price and Overall score
#TRANSFORMATION OF PRICE
fifa_data <- fifa_data %>%
mutate(log_price = log(Price))#Scatter plot after transformation
fifa_data %>%
filter(Price > 0) %>%
ggplot(data = .,aes(x = Overall, y= log_price))+
geom_point()+
geom_vline(xintercept = 65, color = "Red")+
geom_smooth(method = "lm")Figure 3: Linear Regression summary statistics
fifa_data %>%
filter(Price > 0) %>%
lm(formula = log_price ~ Overall, data = .) %>%
summary()
Call:
lm(formula = log_price ~ Overall, data = .)
Residuals:
Min 1Q Median 3Q Max
-3.2226 -0.2069 0.0638 0.3184 1.2384
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.9933480 0.0348885 28.47 <2e-16 ***
Overall 0.1906596 0.0005239 363.90 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.4859 on 17953 degrees of freedom
Multiple R-squared: 0.8806, Adjusted R-squared: 0.8806
F-statistic: 1.324e+05 on 1 and 17953 DF, p-value: < 2.2e-16
Figure 4: Scatter plot showing the average price per playing position
fifa_data %>%
group_by(Position) %>%
summarize(avg_price_position = mean(Price)) %>%
ggplot(data = ., aes(x = Position, y = avg_price_position))+
geom_point()Figure 5: Outlier Identification
fifa_data %>%
slice_max(Price, n=30) %>%
arrange(desc(Price))Figure 6: Analysis of relationship between salary and price of players
fifa_data %>%
ggplot(data = ., aes(x = Price, y = Salary))+
geom_point(alpha = 0.25)+
geom_vline(xintercept = 30000000, color = "red")+
geom_smooth(method = "lm")##Player grouping
fifa_data <- fifa_data %>%
mutate(Grouped_Position = ifelse(fifa_data$Position == 'RF', 'STRIKER',
ifelse(fifa_data$Position == 'CAM', 'MIDFIELD',
ifelse(fifa_data$Position == 'CB', 'DEFENCE',
ifelse(fifa_data$Position == 'CDM', 'MIDFIELD',
ifelse(fifa_data$Position == 'CF', 'STRIKER',
ifelse(fifa_data$Position == 'CM', 'MIDFIELD',
ifelse(fifa_data$Position == 'GK', 'GOAL-KEEPER',
ifelse(fifa_data$Position == 'LAM', 'MIDFIELD',
ifelse(fifa_data$Position == 'LB', 'DEFENCE',
ifelse(fifa_data$Position == 'LCB', 'DEFENCE',
ifelse(fifa_data$Position == 'LDM', 'MIDFIELD',
ifelse(fifa_data$Position == 'LCM', 'MIDFIELD',
ifelse(fifa_data$Position == 'LF', 'WING',
ifelse(fifa_data$Position == 'LM', 'MIDFIELD',
ifelse(fifa_data$Position == 'LW', 'WING',
ifelse(fifa_data$Position == 'LWB', 'DEFENCE',
ifelse(fifa_data$Position == 'RAM', 'MIDFIELD',
ifelse(fifa_data$Position == 'RB', 'DEFENCE',
ifelse(fifa_data$Position == 'RCB', 'DEFENCE',
ifelse(fifa_data$Position == 'RCM', 'MIDFIELD',
ifelse(fifa_data$Position == 'RDM', 'MIDFIELD',
ifelse(fifa_data$Position == 'RF', 'STRIKER',
ifelse(fifa_data$Position == 'RM', 'MIDFIELD',
ifelse(fifa_data$Position == 'RS', 'STRIKER',
ifelse(fifa_data$Position == 'RW', 'WING',
ifelse(fifa_data$Position == 'RWB', 'DEFENCE',
ifelse(fifa_data$Position == 'ST', 'STRIKER',
ifelse(fifa_data$Position == 'LS', 'STRIKER',
'other')))))))))))))))))))))))))))))unique(fifa_data$Grouped_Position)[1] "STRIKER" "WING" "GOAL-KEEPER" "MIDFIELD" "DEFENCE" "other"
##Price analysis
fifa_data %>% # Create a boxplot to understand the outliers (Superstars)
ggplot(data = ., mapping = aes(x= log_price)) +
geom_boxplot()#Calculate the range
range(fifa_data$Price)[1] 0 118500000
#Calculate the Quantiles to see the the distribution of prices under the curve
quantile(fifa_data$Price) 0% 25% 50% 75% 100%
0 300000 675000 2000000 118500000
# Filter data set by price, international reputation, and Potential to create the avg player data set
fifa_data_avg_player <- fifa_data %>%
filter(.data = ., Price < 9000000) #check the range in prices of the avg players
range(fifa_data_avg_player$Price)[1] 0 8500000
#look at the distribution in prices of the avg player
quantile(fifa_data_avg_player$Price) 0% 25% 50% 75% 100%
0 290000 625000 1400000 8500000
fifa_superstars <- fifa_data %>%
filter(., Price > 9000000) #number of superstar that we are not considering that are valued over $9,000,000 i.e SuperStarsfifa_data_avg_player %>%
group_by(Grouped_Position) %>%
count() ##Superstar Averages
superstar_avg = fifa_superstars %>%
group_by(Grouped_Position) %>%
summarise(across(everything(), mean))##Identifying stastically significant skills per position Playing position: STRIKER
#Finding out important attributes for Strikers players
fifa_data_avg_player %>%
filter(Price > 0 & Grouped_Position == "STRIKER") %>%
lm(formula = log_price ~ Crossing+Finishing+HeadingAccuracy+ShortPassing+Volleys+Dribbling+Curve+FKAccuracy+LongPassing+BallControl+Acceleration+SprintSpeed+Agility+Reactions+Balance+ShotPower+Jumping+Stamina+Strength+LongShots+Aggression+Interceptions+Positioning+Vision+Penalties+Composure+Marking+StandingTackle+SlidingTackle+GKDiving+GKHandling+GKKicking+GKReflexes, data = .) %>%
summary()
Call:
lm(formula = log_price ~ Crossing + Finishing + HeadingAccuracy +
ShortPassing + Volleys + Dribbling + Curve + FKAccuracy +
LongPassing + BallControl + Acceleration + SprintSpeed +
Agility + Reactions + Balance + ShotPower + Jumping + Stamina +
Strength + LongShots + Aggression + Interceptions + Positioning +
Vision + Penalties + Composure + Marking + StandingTackle +
SlidingTackle + GKDiving + GKHandling + GKKicking + GKReflexes,
data = .)
Residuals:
Min 1Q Median 3Q Max
-1.33350 -0.21454 0.00447 0.23684 1.76186
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.516e+00 1.233e-01 12.288 < 2e-16 ***
Crossing -5.232e-03 9.750e-04 -5.367 8.79e-08 ***
Finishing 4.499e-02 2.236e-03 20.125 < 2e-16 ***
HeadingAccuracy 1.528e-02 1.351e-03 11.307 < 2e-16 ***
ShortPassing 1.480e-02 1.696e-03 8.730 < 2e-16 ***
Volleys -3.743e-03 1.211e-03 -3.092 0.002014 **
Dribbling 1.716e-02 2.006e-03 8.559 < 2e-16 ***
Curve 1.920e-03 1.009e-03 1.903 0.057177 .
FKAccuracy -1.215e-03 8.591e-04 -1.414 0.157390
LongPassing 5.201e-04 1.121e-03 0.464 0.642765
BallControl 2.759e-02 2.281e-03 12.096 < 2e-16 ***
Acceleration 1.267e-02 1.493e-03 8.487 < 2e-16 ***
SprintSpeed 1.381e-02 1.448e-03 9.535 < 2e-16 ***
Agility -4.277e-03 1.147e-03 -3.729 0.000197 ***
Reactions 1.495e-02 1.673e-03 8.938 < 2e-16 ***
Balance -2.611e-03 9.668e-04 -2.701 0.006971 **
ShotPower 1.852e-02 1.664e-03 11.127 < 2e-16 ***
Jumping -5.901e-04 8.186e-04 -0.721 0.471067
Stamina 1.238e-03 8.697e-04 1.423 0.154805
Strength 3.943e-03 9.506e-04 4.148 3.47e-05 ***
LongShots 3.582e-03 1.571e-03 2.281 0.022660 *
Aggression -1.184e-03 6.453e-04 -1.834 0.066725 .
Interceptions -4.314e-03 9.628e-04 -4.480 7.80e-06 ***
Positioning 2.105e-02 1.848e-03 11.394 < 2e-16 ***
Vision 2.562e-03 1.268e-03 2.021 0.043423 *
Penalties -2.938e-03 1.145e-03 -2.566 0.010351 *
Composure -2.933e-03 1.399e-03 -2.097 0.036101 *
Marking -6.475e-06 7.528e-04 -0.009 0.993138
StandingTackle 2.539e-03 1.388e-03 1.829 0.067477 .
SlidingTackle -9.909e-04 1.462e-03 -0.678 0.497953
GKDiving -1.662e-03 2.352e-03 -0.706 0.479950
GKHandling -7.020e-03 2.352e-03 -2.984 0.002870 **
GKKicking -7.874e-03 2.347e-03 -3.355 0.000807 ***
GKReflexes -2.971e-03 2.348e-03 -1.266 0.205784
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.3517 on 2397 degrees of freedom
Multiple R-squared: 0.9104, Adjusted R-squared: 0.9092
F-statistic: 738.5 on 33 and 2397 DF, p-value: < 2.2e-16
Playing position:WING
#Finding out important attributes for Wing players
fifa_data_avg_player %>%
filter(Price > 0 & Grouped_Position == "WING") %>%
lm(formula = log_price ~ Crossing+Finishing+HeadingAccuracy+ShortPassing+Volleys+Dribbling+Curve+FKAccuracy+LongPassing+BallControl+Acceleration+SprintSpeed+Agility+Reactions+Balance+ShotPower+Jumping+Stamina+Strength+LongShots+Aggression+Interceptions+Positioning+Vision+Penalties+Composure+Marking+StandingTackle+SlidingTackle+GKDiving+GKHandling+GKKicking+GKReflexes, data = .) %>%
summary()
Call:
lm(formula = log_price ~ Crossing + Finishing + HeadingAccuracy +
ShortPassing + Volleys + Dribbling + Curve + FKAccuracy +
LongPassing + BallControl + Acceleration + SprintSpeed +
Agility + Reactions + Balance + ShotPower + Jumping + Stamina +
Strength + LongShots + Aggression + Interceptions + Positioning +
Vision + Penalties + Composure + Marking + StandingTackle +
SlidingTackle + GKDiving + GKHandling + GKKicking + GKReflexes,
data = .)
Residuals:
Min 1Q Median 3Q Max
-1.38999 -0.21500 -0.00023 0.22006 1.46681
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.1908575 0.2381362 5.001 7.38e-07 ***
Crossing 0.0002799 0.0024007 0.117 0.90723
Finishing 0.0230509 0.0029409 7.838 1.91e-14 ***
HeadingAccuracy 0.0009490 0.0016562 0.573 0.56687
ShortPassing 0.0286917 0.0039270 7.306 8.21e-13 ***
Volleys -0.0030636 0.0020632 -1.485 0.13807
Dribbling 0.0395802 0.0041069 9.638 < 2e-16 ***
Curve 0.0013492 0.0021479 0.628 0.53012
FKAccuracy -0.0007493 0.0016454 -0.455 0.64900
LongPassing -0.0028894 0.0024602 -1.174 0.24066
BallControl 0.0380805 0.0046143 8.253 8.85e-16 ***
Acceleration 0.0157981 0.0036103 4.376 1.41e-05 ***
SprintSpeed 0.0101024 0.0032823 3.078 0.00217 **
Agility 0.0069129 0.0022584 3.061 0.00230 **
Reactions 0.0113778 0.0026221 4.339 1.66e-05 ***
Balance -0.0038561 0.0018950 -2.035 0.04227 *
ShotPower 0.0047774 0.0025076 1.905 0.05721 .
Jumping -0.0008994 0.0012185 -0.738 0.46071
Stamina -0.0015597 0.0015445 -1.010 0.31295
Strength -0.0018130 0.0014708 -1.233 0.21816
LongShots 0.0023242 0.0023398 0.993 0.32092
Aggression 0.0010249 0.0013276 0.772 0.44041
Interceptions -0.0014509 0.0016889 -0.859 0.39062
Positioning 0.0168654 0.0030731 5.488 5.86e-08 ***
Vision 0.0088245 0.0027686 3.187 0.00151 **
Penalties 0.0003200 0.0018412 0.174 0.86210
Composure -0.0060656 0.0026096 -2.324 0.02042 *
Marking -0.0011175 0.0013160 -0.849 0.39610
StandingTackle 0.0017219 0.0026171 0.658 0.51080
SlidingTackle 0.0005470 0.0026116 0.209 0.83416
GKDiving 0.0007695 0.0042722 0.180 0.85712
GKHandling -0.0019217 0.0043270 -0.444 0.65711
GKKicking 0.0020192 0.0043011 0.469 0.63890
GKReflexes -0.0097271 0.0042956 -2.264 0.02388 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.3325 on 640 degrees of freedom
Multiple R-squared: 0.9109, Adjusted R-squared: 0.9063
F-statistic: 198.3 on 33 and 640 DF, p-value: < 2.2e-16
Playing position:MIDFIELD
#filtering for MIDFIELD players
fifa_data_avg_player %>%
filter(Price > 0 & Grouped_Position == "MIDFIELD") %>%
lm(formula = log_price ~ Crossing+Finishing+HeadingAccuracy+ShortPassing+Volleys+Dribbling+Curve+FKAccuracy+LongPassing+BallControl+Acceleration+SprintSpeed+Agility+Reactions+Balance+ShotPower+Jumping+Stamina+Strength+LongShots+Aggression+Interceptions+Positioning+Vision+Penalties+Composure+Marking+StandingTackle+SlidingTackle+GKDiving+GKHandling+GKKicking+GKReflexes, data = .) %>%
summary()
Call:
lm(formula = log_price ~ Crossing + Finishing + HeadingAccuracy +
ShortPassing + Volleys + Dribbling + Curve + FKAccuracy +
LongPassing + BallControl + Acceleration + SprintSpeed +
Agility + Reactions + Balance + ShotPower + Jumping + Stamina +
Strength + LongShots + Aggression + Interceptions + Positioning +
Vision + Penalties + Composure + Marking + StandingTackle +
SlidingTackle + GKDiving + GKHandling + GKKicking + GKReflexes,
data = .)
Residuals:
Min 1Q Median 3Q Max
-2.8560 -0.2904 0.0010 0.2977 4.6442
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.3873342 0.1049614 13.218 < 2e-16 ***
Crossing 0.0005895 0.0009214 0.640 0.5223
Finishing 0.0046988 0.0010002 4.698 2.69e-06 ***
HeadingAccuracy 0.0063712 0.0008132 7.835 5.47e-15 ***
ShortPassing 0.0382627 0.0020015 19.117 < 2e-16 ***
Volleys -0.0064730 0.0008724 -7.420 1.33e-13 ***
Dribbling 0.0232587 0.0016916 13.749 < 2e-16 ***
Curve 0.0005979 0.0009166 0.652 0.5142
FKAccuracy -0.0051202 0.0007972 -6.422 1.44e-10 ***
LongPassing 0.0059561 0.0015142 3.933 8.46e-05 ***
BallControl 0.0495768 0.0020837 23.792 < 2e-16 ***
Acceleration 0.0135813 0.0012716 10.680 < 2e-16 ***
SprintSpeed 0.0105988 0.0011517 9.202 < 2e-16 ***
Agility -0.0012798 0.0009962 -1.285 0.1989
Reactions 0.0256071 0.0012652 20.240 < 2e-16 ***
Balance -0.0045127 0.0008728 -5.171 2.41e-07 ***
ShotPower 0.0085062 0.0010750 7.913 2.96e-15 ***
Jumping -0.0028407 0.0006091 -4.664 3.17e-06 ***
Stamina 0.0108043 0.0006998 15.439 < 2e-16 ***
Strength -0.0021733 0.0007648 -2.842 0.0045 **
LongShots 0.0009019 0.0009844 0.916 0.3596
Aggression 0.0003529 0.0006753 0.523 0.6012
Interceptions -0.0013366 0.0008714 -1.534 0.1251
Positioning -0.0043135 0.0010462 -4.123 3.79e-05 ***
Vision 0.0117389 0.0012936 9.074 < 2e-16 ***
Penalties -0.0017317 0.0008624 -2.008 0.0447 *
Composure 0.0046467 0.0010800 4.302 1.72e-05 ***
Marking 0.0011440 0.0006936 1.649 0.0991 .
StandingTackle 0.0003005 0.0013176 0.228 0.8196
SlidingTackle -0.0004937 0.0011850 -0.417 0.6770
GKDiving -0.0017034 0.0019665 -0.866 0.3864
GKHandling 0.0015909 0.0019997 0.796 0.4263
GKKicking -0.0010050 0.0019570 -0.514 0.6076
GKReflexes -0.0010012 0.0019664 -0.509 0.6107
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.4748 on 6200 degrees of freedom
Multiple R-squared: 0.8411, Adjusted R-squared: 0.8403
F-statistic: 994.7 on 33 and 6200 DF, p-value: < 2.2e-16
Playing position:DEFENCE
#filtering for DEFENCE players
fifa_data_avg_player %>%
filter(Price > 0 & Grouped_Position == "DEFENCE") %>%
lm(formula = log_price ~ Crossing+Finishing+HeadingAccuracy+ShortPassing+Volleys+Dribbling+Curve+FKAccuracy+LongPassing+BallControl+Acceleration+SprintSpeed+Agility+Reactions+Balance+ShotPower+Jumping+Stamina+Strength+LongShots+Aggression+Interceptions+Positioning+Vision+Penalties+Composure+Marking+StandingTackle+SlidingTackle+GKDiving+GKHandling+GKKicking+GKReflexes, data = .) %>%
summary()
Call:
lm(formula = log_price ~ Crossing + Finishing + HeadingAccuracy +
ShortPassing + Volleys + Dribbling + Curve + FKAccuracy +
LongPassing + BallControl + Acceleration + SprintSpeed +
Agility + Reactions + Balance + ShotPower + Jumping + Stamina +
Strength + LongShots + Aggression + Interceptions + Positioning +
Vision + Penalties + Composure + Marking + StandingTackle +
SlidingTackle + GKDiving + GKHandling + GKKicking + GKReflexes,
data = .)
Residuals:
Min 1Q Median 3Q Max
-2.6104 -0.2651 0.0265 0.3113 4.4003
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.6563473 0.1137571 14.560 < 2e-16 ***
Crossing -0.0115399 0.0008419 -13.706 < 2e-16 ***
Finishing 0.0023505 0.0009617 2.444 0.014548 *
HeadingAccuracy 0.0144550 0.0011653 12.405 < 2e-16 ***
ShortPassing 0.0169758 0.0014669 11.573 < 2e-16 ***
Volleys -0.0009286 0.0008861 -1.048 0.294688
Dribbling 0.0049042 0.0010530 4.657 3.28e-06 ***
Curve 0.0014955 0.0008463 1.767 0.077275 .
FKAccuracy -0.0009494 0.0008187 -1.160 0.246248
LongPassing -0.0021353 0.0010710 -1.994 0.046228 *
BallControl 0.0122519 0.0014595 8.394 < 2e-16 ***
Acceleration 0.0082434 0.0012618 6.533 7.04e-11 ***
SprintSpeed 0.0178852 0.0011496 15.558 < 2e-16 ***
Agility -0.0020786 0.0009487 -2.191 0.028490 *
Reactions 0.0181855 0.0015610 11.650 < 2e-16 ***
Balance -0.0055301 0.0008954 -6.176 7.05e-10 ***
ShotPower 0.0035806 0.0008155 4.390 1.15e-05 ***
Jumping -0.0009240 0.0007148 -1.293 0.196156
Stamina 0.0093118 0.0008300 11.219 < 2e-16 ***
Strength 0.0022076 0.0010024 2.202 0.027693 *
LongShots -0.0038162 0.0009100 -4.194 2.79e-05 ***
Aggression 0.0025794 0.0008817 2.925 0.003456 **
Interceptions 0.0185252 0.0017078 10.847 < 2e-16 ***
Positioning -0.0021971 0.0008757 -2.509 0.012139 *
Vision -0.0017855 0.0009522 -1.875 0.060831 .
Penalties -0.0021686 0.0008690 -2.496 0.012603 *
Composure -0.0039358 0.0011715 -3.360 0.000786 ***
Marking 0.0238039 0.0014564 16.344 < 2e-16 ***
StandingTackle 0.0455553 0.0025419 17.922 < 2e-16 ***
SlidingTackle 0.0186257 0.0022187 8.395 < 2e-16 ***
GKDiving 0.0010599 0.0021576 0.491 0.623277
GKHandling -0.0029921 0.0021736 -1.377 0.168702
GKKicking -0.0046790 0.0020928 -2.236 0.025407 *
GKReflexes -0.0016938 0.0021734 -0.779 0.435814
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.4859 on 5473 degrees of freedom
Multiple R-squared: 0.8268, Adjusted R-squared: 0.8258
F-statistic: 791.7 on 33 and 5473 DF, p-value: < 2.2e-16
Playing position:GOAL-KEEPER
#filtering for GOAL-KEEPER players
fifa_data_avg_player %>%
filter(Price > 0 & Grouped_Position == "GOAL-KEEPER") %>%
lm(formula = log_price ~ Crossing+Finishing+HeadingAccuracy+ShortPassing+Volleys+Dribbling+Curve+FKAccuracy+LongPassing+BallControl+Acceleration+SprintSpeed+Agility+Reactions+Balance+ShotPower+Jumping+Stamina+Strength+LongShots+Aggression+Interceptions+Positioning+Vision+Penalties+Composure+Marking+StandingTackle+SlidingTackle+GKDiving+GKHandling+GKKicking+GKReflexes, data = .) %>%
summary()
Call:
lm(formula = log_price ~ Crossing + Finishing + HeadingAccuracy +
ShortPassing + Volleys + Dribbling + Curve + FKAccuracy +
LongPassing + BallControl + Acceleration + SprintSpeed +
Agility + Reactions + Balance + ShotPower + Jumping + Stamina +
Strength + LongShots + Aggression + Interceptions + Positioning +
Vision + Penalties + Composure + Marking + StandingTackle +
SlidingTackle + GKDiving + GKHandling + GKKicking + GKReflexes,
data = .)
Residuals:
Min 1Q Median 3Q Max
-3.0622 -0.2044 0.0853 0.3420 1.3112
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.5942850 0.1680786 9.485 < 2e-16 ***
Crossing -0.0069668 0.0041362 -1.684 0.092284 .
Finishing 0.0008992 0.0051911 0.173 0.862493
HeadingAccuracy 0.0030268 0.0038289 0.791 0.429318
ShortPassing 0.0021277 0.0024034 0.885 0.376125
Volleys -0.0073119 0.0047757 -1.531 0.125921
Dribbling 0.0001951 0.0039932 0.049 0.961044
Curve 0.0112072 0.0038155 2.937 0.003351 **
FKAccuracy -0.0072472 0.0035191 -2.059 0.039592 *
LongPassing 0.0019851 0.0023130 0.858 0.390864
BallControl -0.0059622 0.0028935 -2.061 0.039483 *
Acceleration 0.0081631 0.0023485 3.476 0.000521 ***
SprintSpeed 0.0008019 0.0023696 0.338 0.735084
Agility -0.0039030 0.0015197 -2.568 0.010296 *
Reactions 0.0072068 0.0022905 3.146 0.001679 **
Balance -0.0008057 0.0015447 -0.522 0.602046
ShotPower 0.0035778 0.0021621 1.655 0.098127 .
Jumping -0.0030445 0.0015474 -1.967 0.049274 *
Stamina 0.0038081 0.0020760 1.834 0.066752 .
Strength 0.0001276 0.0013510 0.094 0.924755
LongShots 0.0028381 0.0047439 0.598 0.549732
Aggression -0.0160938 0.0019230 -8.369 < 2e-16 ***
Interceptions -0.0042204 0.0031320 -1.347 0.177986
Positioning -0.0157758 0.0048243 -3.270 0.001095 **
Vision 0.0023417 0.0012342 1.897 0.057928 .
Penalties -0.0069203 0.0023399 -2.958 0.003140 **
Composure -0.0071827 0.0013829 -5.194 2.28e-07 ***
Marking -0.0079515 0.0024770 -3.210 0.001349 **
StandingTackle 0.0134768 0.0049973 2.697 0.007063 **
SlidingTackle -0.0009553 0.0048799 -0.196 0.844821
GKDiving 0.0505630 0.0043600 11.597 < 2e-16 ***
GKHandling 0.0424519 0.0035073 12.104 < 2e-16 ***
GKKicking 0.0115107 0.0027443 4.194 2.86e-05 ***
GKReflexes 0.0773435 0.0041440 18.664 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.5788 on 1880 degrees of freedom
Multiple R-squared: 0.8129, Adjusted R-squared: 0.8097
F-statistic: 247.6 on 33 and 1880 DF, p-value: < 2.2e-16
##Player Identification ###FILTERING FOR STRIKERS - 2 Main SKILLS
fifa_data_avg_player %>%
filter(Grouped_Position == "STRIKER") %>%
filter(Finishing >= 80.70 & HeadingAccuracy >= 73.98) %>%
arrange(desc(Price))###FILTERING FOR WING - 2 Main SKILLS
fifa_data_avg_player %>%
filter(Grouped_Position == "WING") %>%
filter(SprintSpeed >= 82.84 & Crossing >= 75.82) %>%
arrange(desc(Price))###Filtering for midfield - 2 main SKILLS
fifa_data_avg_player %>%
filter(Grouped_Position == "MIDFIELD") %>%
filter(ShortPassing >= 79.67 & BallControl >= 80.84) %>%
arrange(desc(Price))###FILTERING FOR DEFENCE - 2 Main SKILLS
fifa_data_avg_player %>%
filter(Grouped_Position == "DEFENCE") %>%
filter(Strength >= 77.35 & SlidingTackle >= 79.7 & StandingTackle >= 81) %>%
arrange(desc(Price))###FILTERING FOR Goal-keeper - 2 Main SKILLS
fifa_data_avg_player %>%
filter(Grouped_Position == "GOAL-KEEPER") %>%
filter(GKDiving >= 82.34 & GKReflexes > 84.01 ) %>%
arrange(desc(Price))###Predicting Prices (Strikers) with Linear regression formula
lm_strikers = fifa_data_avg_player %>%
filter(Price > 0 & Grouped_Position == "STRIKER") %>%
lm(formula = log_price ~ Crossing+Finishing+HeadingAccuracy+ShortPassing+Volleys+Dribbling+Curve+FKAccuracy+LongPassing+BallControl+Acceleration+SprintSpeed+Agility+Reactions+Balance+ShotPower+Jumping+Stamina+Strength+LongShots+Aggression+Interceptions+Positioning+Vision+Penalties+Composure+Marking+StandingTackle+SlidingTackle+GKDiving+GKHandling+GKKicking+GKReflexes, data = .)
strikers_filtered = fifa_data_avg_player %>%
filter(Grouped_Position == "STRIKER" & Price > 0)
predict_p_df = as_data_frame(broom::augment(lm_strikers))
strikers_predited <- cbind(strikers_filtered, predict_p_df$.fitted)
strikers_predited %>%
filter(`predict_p_df$.fitted`< log_price)NA
NA###Predicting Prices (Wing) with Linear regression formula
lm_wing = fifa_data_avg_player %>%
filter(Price > 0 & Grouped_Position == "WING") %>%
lm(formula = log_price ~ Crossing+Finishing+HeadingAccuracy+ShortPassing+Volleys+Dribbling+Curve+FKAccuracy+LongPassing+BallControl+Acceleration+SprintSpeed+Agility+Reactions+Balance+ShotPower+Jumping+Stamina+Strength+LongShots+Aggression+Interceptions+Positioning+Vision+Penalties+Composure+Marking+StandingTackle+SlidingTackle+GKDiving+GKHandling+GKKicking+GKReflexes, data = .)
wing_filtered = fifa_data_avg_player %>%
filter(Grouped_Position == "WING" & Price > 0)
predict_wing_df = as_data_frame(broom::augment(lm_wing))
wing_predited <- cbind(wing_filtered, predict_wing_df$.fitted)
wing_predited %>%
filter(`predict_wing_df$.fitted`< log_price)###Predicting Prices (MIDFIELD) with Linear regression formula
lm_midfield = fifa_data_avg_player %>%
filter(Price > 0 & Grouped_Position == "MIDFIELD") %>%
lm(formula = log_price ~ Crossing+Finishing+HeadingAccuracy+ShortPassing+Volleys+Dribbling+Curve+FKAccuracy+LongPassing+BallControl+Acceleration+SprintSpeed+Agility+Reactions+Balance+ShotPower+Jumping+Stamina+Strength+LongShots+Aggression+Interceptions+Positioning+Vision+Penalties+Composure+Marking+StandingTackle+SlidingTackle+GKDiving+GKHandling+GKKicking+GKReflexes, data = .)
midfield_filtered = fifa_data_avg_player %>%
filter(Grouped_Position == "MIDFIELD" & Price > 0)
predict_midfield_df = as_data_frame(broom::augment(lm_midfield))
midfield_predited <- cbind(midfield_filtered, predict_midfield_df$.fitted)
midfield_predited %>%
filter(`predict_midfield_df$.fitted`< log_price)###Predicting Prices (DEFENCE) with Linear regression formula
lm_defence = fifa_data_avg_player %>%
filter(Price > 0 & Grouped_Position == "DEFENCE") %>%
lm(formula = log_price ~ Crossing+Finishing+HeadingAccuracy+ShortPassing+Volleys+Dribbling+Curve+FKAccuracy+LongPassing+BallControl+Acceleration+SprintSpeed+Agility+Reactions+Balance+ShotPower+Jumping+Stamina+Strength+LongShots+Aggression+Interceptions+Positioning+Vision+Penalties+Composure+Marking+StandingTackle+SlidingTackle+GKDiving+GKHandling+GKKicking+GKReflexes, data = .)
defence_filtered = fifa_data_avg_player %>%
filter(Grouped_Position == "DEFENCE" & Price > 0)
predict_defence_df = as_data_frame(broom::augment(lm_defence))
defence_predited <- cbind(defence_filtered, predict_defence_df$.fitted)
defence_predited %>%
filter(`predict_defence_df$.fitted`< log_price)###Predicting Prices (GOAL-KEEPER) with Linear regression formula
lm_goalie = fifa_data_avg_player %>%
filter(Price > 0 & Grouped_Position == "GOAL-KEEPER") %>%
lm(formula = log_price ~ Crossing+Finishing+HeadingAccuracy+ShortPassing+Volleys+Dribbling+Curve+FKAccuracy+LongPassing+BallControl+Acceleration+SprintSpeed+Agility+Reactions+Balance+ShotPower+Jumping+Stamina+Strength+LongShots+Aggression+Interceptions+Positioning+Vision+Penalties+Composure+Marking+StandingTackle+SlidingTackle+GKDiving+GKHandling+GKKicking+GKReflexes, data = .)
goalie_filtered = fifa_data_avg_player %>%
filter(Grouped_Position == "GOAL-KEEPER" & Price > 0)
predict_goalie_df = as_data_frame(broom::augment(lm_goalie))
goalie_predited <- cbind(goalie_filtered, predict_goalie_df$.fitted)
goalie_predited %>%
filter(`predict_goalie_df$.fitted`< log_price)#Output Selecting Top Players for MIDFLIED Position, message=FALSE, warning=FALSE
midfield_predited %>%
filter(ShortPassing >= 79.67 & BallControl >= 80.84 & `predict_midfield_df$.fitted`> log_price) %>%
arrange(desc(Price))Selecting Top Players for GOAL - KEEPER Position, message=FALSE, warning=FALSE
goalie_predited %>%
filter(GKDiving >= 82.34 & GKReflexes > 84.01 & `predict_goalie_df$.fitted`> log_price) %>%
arrange(desc(Price))Selecting Top Players for DEFENCE Position, message=FALSE, warning=FALSE
defence_predited %>%
filter(Strength >= 77.35 & SlidingTackle >= 79.7 & StandingTackle >= 81 & `predict_defence_df$.fitted`> log_price) %>%
arrange(desc(Price))Selecting Top Players for WING Position, message=FALSE, warning=FALSE
wing_predited %>%
filter(SprintSpeed >= 82.84 & Crossing >= 75.82 & `predict_wing_df$.fitted` > log_price) %>%
arrange(desc(Price))Selecting Top Players for STRICKERS Position, message=FALSE, warning=FALSE
strikers_predited %>%
filter(Finishing >= 80.70 & HeadingAccuracy >= 73.98 & `predict_p_df$.fitted`> log_price) %>%
arrange(desc(Price))